package com.thread.example.mythread;

public class MyJoin {

    public static void main(String[] args) {
        Thread thread1 = new Thread(() -> {
            System.out.println("开始运行thread1");
            System.out.println("thread1");
        });
        Thread thread2 = new Thread(() -> {
            System.out.println("开始运行thread2");
            try {
                thread1.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("thread2");
        });
        Thread thread3 = new Thread(() -> {
            System.out.println("开始运行thread3");
            try {
                thread2.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("thread3");
        });

        thread3.start();
        thread1.start();
        thread2.start();
    }
}
